<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel common\models\MktChatSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '私信';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="mkt-chat-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <?php echo Html::a('创建', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?php echo GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            //['class' => 'yii\grid\SerialColumn'],

            //'id',
            'sender_id',
            [
                'label' => '发送者姓名',
                'attribute' => 'sender_id',
                //'filter' => false,
                'headerOptions' => array('style'=>'width:80px;'),     
                'value'=>function ($model, $key, $index, $column) { 
                    return $model->sender->name;
                },
                
            ],

            'recver_id',

            [
                'label' => '接收者姓名',
                'attribute' => 'recver_id',
                //'filter' => false,
                'headerOptions' => array('style'=>'width:80px;'),     
                'value'=>function ($model, $key, $index, $column) { 
                    return $model->recver->name;
                },                
            ],

            [
                'attribute' => 'cat',
                'value'=>function ($model, $key, $index, $column) { 
                        return \common\models\MktChat::getCatOption($model->cat); 
                 },
                'filter'=> \common\models\MktChat::getCatOption(),
            ],

            [
                'label' => '状态',
                'attribute' => 'approve',
                'value'=>function ($model, $key, $index, $column) { 
                        return \common\models\MktChat::getApproveStatusOption($model->approved); 
                 },
                'filter'=> \common\models\MktChat::getApproveStatusOption(),
            ],

            'content:ntext',
            'is_read',
            // 'is_deleted',
            'create_time',
            // 'update_time',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>

</div>
